package cn.edu.nju.software;

import java.awt.Component;
import java.awt.Frame;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;

import abbot.editor.HierarchyWriter;
import abbot.finder.AWTHierarchy;
import abbot.finder.BasicFinder;
import abbot.finder.Hierarchy;

public class Main {

	public static void main(String args[]) {
		Launch launch = new Launch("abbot.editor.ScriptEditor", null, null,
				"D:\\abbot-1.2.0\\lib\\costello.jar");
		Thread runApp = new Thread(launch);
		// runApp.start();
		// try {
		// Thread.sleep(5000);
		// } catch (InterruptedException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }
		abbot.editor.ScriptEditor.main(args);
		Hierarchy hier = AWTHierarchy.getDefault();
		HierarchyWriter hw=new HierarchyWriter(hier);
		BasicFinder bf=new BasicFinder();
		Hierarchy hier2=bf.
		File file=new File("a");
		try {
			hw.writeHierarchy(new FileWriter(file));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		Collection<Component> roots = hier.getRoots();
		Iterator it=roots.iterator();
		while(it.hasNext()){
			Component cm=(Component)it.next();
			Collection<Component> subCom=hier.getComponents(cm);
			System.out.println(subCom);
		}
		Frame[] tem=Frame.getFrames();
		for(int i=0;i<tem.length;i++){
			Component[] comps=tem[i].getComponents();
			System.out.println(comps);
		}

	}
}
